<!--
 * @Author: 筱洛 3259871097@qq.com
 * @Date: 2025-04-09 17:01:37
 * @LastEditors: 筱洛 3259871097@qq.com
 * @LastEditTime: 2025-04-09 19:33:00
 * @FilePath: \Exam system\src\components\HelloWorld.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- filePath: examination - 1/view/components/HelloWorld.vue -->
<template>
  <div class="greetings">
    <h1 class="green">{{ msg }}</h1>
    <h3>
      You’ve successfully created a project with
      <a href="https://vite.dev/" target="_blank" rel="noopener">Vite</a> +
      <a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>.
    </h3>
    <button @click="fetchUser">Get User</button>
    <p>{{ userInfo }}</p>
  </div>
</template>

<script setup>
import { ref } from 'vue';
import { getUser } from '../api/user';

const msg = 'Hello World!';
const userInfo = ref('');

const fetchUser = async () => {
    try {
        const response = await getUser();
        userInfo.value = response.data;
    } catch (error) {
        console.error('Error fetching user:', error);
    }
};
</script>